package com.situ.service.impl;



import java.util.Date;
import java.util.List;
import java.util.Map;


import java.util.*;



import com.situ.entity.FuHeFaPiao;
import com.situ.entity.FuHeFaPiaomingxi;
import com.situ.entity.IvIninvoice;
import com.situ.entity.SyEmp;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.situ.service.IvInvoiceService;
import com.situ.dao.FuHeFaPiaoDao;
import com.situ.dao.IvInvoiceDao;
import com.situ.entity.IvInvoice;

/**
 * IvInvoice的服务接口的实现类
 *
 * @author
 */
@Service
public class IvInvoiceServiceImpl implements IvInvoiceService {
    private final Logger LOG = LogManager.getLogger(this.getClass());

    @Autowired
    private IvInvoiceDao ivInvoiceDao;
    // TODO 当你看到这个方法时你应该创建一个工具类做通用的方法,定义自己的返回格式化
    private static final int C200 = 200;
    private static final int C412 = 412;

    public String resultFormat(int code, Object data) {
        JSONObject result = new JSONObject();
        result.put("code", code);
        if (data != null) {
            result.put("data", data);
        }
        return result.toJSONString();
    }

    @Override
    public List<Map> queryAll() {
        return ivInvoiceDao.queryAll();
    }



	
	@Autowired
	private FuHeFaPiaoDao fuhedao;
	

    @Override
    public IvInvoice findOne(String id) {
        if (id == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("执行通过IvInvoice的id获得IvInvoice对象-->失败:id不能为空");
            }
            return null;
        }
        IvInvoice result = ivInvoiceDao.selectIvInvoiceById(id);
        if (LOG.isDebugEnabled()) {
            LOG.debug("执行通过IvInvoice的id获得IvInvoice对象-->结果:", result);
        }
        return result;
    }




    @Override
    public String saveNotNull(IvInvoice value) {
        if (value == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("执行将IvInvoice中属性值不为null的数据保存到数据库-->失败:对象不能为空");
            }
            return resultFormat(C412, null);
        }
        int result = ivInvoiceDao.insertNotNullIvInvoice(value);
        if (LOG.isDebugEnabled()) {
            LOG.debug("执行将IvInvoice中属性值不为null的数据保存到数据库-->结果:", result);
        }
        return resultFormat(C200, result);
    }

    @Override
    public String updateNotNullById(IvInvoice value) {
        if (value == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("执行通过IvInvoice的id更新IvInvoice中属性不为null的数据-->失败:对象为null");
            }
            return resultFormat(C412, null);
        }
        int result = ivInvoiceDao.updateNotNullIvInvoiceById(value);
        if (LOG.isDebugEnabled()) {
            LOG.debug("执行通过IvInvoice的id更新IvInvoice中属性不为null的数据-->结果:", result);
        }
        return resultFormat(C200, result);
    }

    @Override
    public String deleteById(String id) {
        if (id == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("执行通过IvInvoice的id删除IvInvoice-->失败:id不能为空");
            }
            return resultFormat(C412, null);
        }
        int result = ivInvoiceDao.deleteIvInvoiceById(id);
        if (LOG.isDebugEnabled()) {
            LOG.debug("执行通过IvInvoice的id删除IvInvoice-->结果:", result);
        }
        return resultFormat(C200, result);
    }

	@Override
	public List<Map> queryhuizong() {
		return ivInvoiceDao.queryhuizong();
	}

	@Override
	public List<Map> queryzmoney() {
		return ivInvoiceDao.queryzmoney();
	}

    @Override
    public List<SyEmp> queryxialaemp() {
        return ivInvoiceDao.queryxialaemp();
    }

	@Override
	public List<Map> querymingxi() {
		return ivInvoiceDao.querymingxi();
	}

	@Override
	public int queryzshu() {
		return ivInvoiceDao.queryzshu();
	}

	@Override
	public int queryusezshu() {
		return ivInvoiceDao.queryusezshu();
	}

	@Override
	public int queryzuofeizshu() {
		return ivInvoiceDao.queryzuofeizshu();
	}

	@Override
	public int queryzjmoney() {
		return ivInvoiceDao.queryzjmoney();
	}

	@Override
	public List<Map> queryzong() {
		// TODO Auto-generated method stub
		return ivInvoiceDao.queryzong();
	}

	@Override
	public List<Map> queryyongshuixiaoz() {
		// TODO Auto-generated method stub
		return ivInvoiceDao.queryyongshuixiaoz();
	}

	@Override
	public List<Map> queryxiaozhanmingxi() {
		// TODO Auto-generated method stub
		return ivInvoiceDao.queryxiaozhanmingxi();
	}

	@Override
	public List<Map> queryhuizonggaoji(int EmpID, int InvoiceType) {
		// TODO Auto-generated method stub
		return ivInvoiceDao.queryhuizonggaoji(EmpID, InvoiceType);
	}

	@Override
	public List<Map> findhuizonggaoji(FuHeFaPiao fuhe) {
		// TODO Auto-generated method stub
		return ivInvoiceDao.findhuizonggaoji(fuhe);
	}

	@Override
	public List<Map> findmingxigaoji(FuHeFaPiao fuhe) {
		// TODO Auto-generated method stub
		return ivInvoiceDao.findmingxigaoji(fuhe);
	}

	@Override
	public List<IvInvoice> find(IvInvoice value) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public IvInvoice findOne(Object id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Map> Findxiaozhanmingxigaoji(FuHeFaPiaomingxi fuhe) {
		// TODO Auto-generated method stub
		return ivInvoiceDao.Findxiaozhanmingxigaoji(fuhe);
	}



}